package com.jjxy.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jjxy.ICheckItemService;
import com.jjxy.dao.ICheckItemDao;
import com.jjxy.entity.PageResult;
import com.jjxy.entity.QueryPageBean;
import com.jjxy.pojo.CheckItem;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ICheckItemServiceImpl implements ICheckItemService {
    @Resource
    private ICheckItemDao checkItemDao;

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {

        if ("null".equals(queryPageBean.getQueryString())) {
            queryPageBean.setQueryString(null);
        }
        PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        Page<CheckItem> page = checkItemDao.findPage(queryPageBean.getQueryString());
        System.out.println(page.getTotal());
        System.out.println(page.getResult());
        PageResult pageResult = new PageResult(page.getTotal(), page.getResult());
        return pageResult;
    }

    @Override
    public void add(CheckItem checkItem) {
        checkItemDao.add(checkItem);
    }

    @Override
    public void edit(CheckItem checkItem) {
        checkItemDao.edit(checkItem);
    }

    @Override
    public void delete(Integer id) {
        checkItemDao.delete(id);
    }
}